package com.tarena.lbs.activity.rpc;

import com.tarena.lbs.activity.api.ActivityApi;
import com.tarena.lbs.activity.api.pojo.ActivityDto;
import com.tarena.lbs.activity.service.ActivityService;
import com.tarena.lbs.base.protocol.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@DubboService
public class ActivityApiImpl implements ActivityApi {

    @Autowired
    private ActivityService activityService;

    /**
     * 判断用户是否可以参与此活动
     * @param userId 用户id
     * @param activityId 活动id
     * @return
     */
    @Override
    public Boolean activityVisible(Integer userId, Integer activityId) throws BusinessException {
        log.debug("判断用户是否可以参与此活动：userid={}, activityId={}",userId,activityId);
        return activityService.activityVisible(userId,activityId);
    }

    /**
     * 根据活动id查询活动详情
     * @param activityId 活动id
     * @return
     */
    @Override
    public ActivityDto getActivityById(Integer activityId) throws BusinessException {
        log.debug("根据活动id查询活动详情：activityId={}",activityId);
       return activityService.getActivityById(activityId);
    }
}
